package top.humbleyuan.test.GuangLianDa;

import java.util.*;

/**
 * @Author HumbleYuan
 * @Date 2020/4/29 16:13
 * @Des
 */
public class GuangLianDa_4_29 {
    public static void main(String[] args) {
        m1();


        // 钢筋拼接
        //m2();

//        Scanner sc = new Scanner(System.in);
//
//        while(sc.hasNext()) {
//            int num = sc.nextInt();
//
//            String[] arr = {"2,4,1,3", "3,1,4,2"};
//            for (int i = 4; i < num; i++) {
//                String[] newArr = new String[(num - 2) * 2];
//
//                for (int j = 0; j < arr.length; j++) {
//
//                }
//            }
//        }
//
//        sc.close();
    }

    private static void m2() {
        Scanner sc = new Scanner(System.in);

        while(sc.hasNext()) {
            List<Integer> nums = new ArrayList<>();

            if(nums.size() <= 3) {
                System.out.println(false);
                return;
            }

            int sum = 0;
            for (Integer i : nums) {
                sum += nums.get(i);
            }

            if(sum % 4 != 0) {
                System.out.println(false);
                return;
            }

            int each = sum / 4;

            for (int i = 0; i < nums.size(); i++) {
                if(nums.get(i) > each) {
                    System.out.println(false);
                    return;
                }


            }
        }

        sc.close();
    }


    // https://blog.csdn.net/Cheng_MY/article/details/102533673
    private static void m1() {
        Scanner sc = new Scanner(System.in);

        while(sc.hasNext()) {
            String getIn = sc.nextLine();
            getIn = getIn.substring(1, getIn.length() - 1);

            String[] pStr = getIn.split("\\],");
            String last = pStr[pStr.length - 1];
            pStr[pStr.length - 1] = last.substring(0, last.length() - 1);

            int[][] person = new int[pStr.length][2];
            for (int i = 0; i < pStr.length; i++) {
                String cur = pStr[i].substring(1);
                person[i][0] = Integer.valueOf(cur.split(",")[0]);
                person[i][1] = Integer.valueOf(cur.split(",")[1]);
            }

            Arrays.sort(person, (o1, o2) -> o1[0] == o2[0] ? o1[1] - o2[1] : o2[0] - o1[0]);

            LinkedList<int[]> list = new LinkedList<>();
            for (int[] i : person) {
                list.add(i[1], i);
            }

            String res = "";
            //System.out.println(list.toArray());
        }

        sc.close();
    }


}
